package com.lingxu.api.ztb.controller;


import com.lingxu.api.ztb.model.vo.CimsProjectSectionInfoVO;
import com.lingxu.api.ztb.service.IZtbParagraphService;
import com.lingxu.api.ztb.model.ZtbParagraph;
import com.lingxu.api.ztb.model.vo.ZtbParagraphVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.lingxu.base.common.api.vo.Result;
import com.lingxu.base.common.api.vo.ResultOne;
import com.lingxu.base.common.annotation.Encrypt;

import lombok.extern.slf4j.Slf4j;
import java.util.Set;

/**
 * 标段表 前端控制器
 *
 * @author admin
 * @since 2025-07-18
 */
@Slf4j
@Api(tags = "标段表", value = "ZtbParagraphController")
@Validated
@CrossOrigin
@RestController
@RequestMapping("/ztbParagraph")
public class ZtbParagraphController {

    @Autowired
    private IZtbParagraphService  ztbParagraphService;

    /**
     * 分页查询
     *
     * @param query
     * @return
     */
    @ApiOperation(value="标段表列表")
    @PostMapping(value = "/list")
    public ResultOne<ZtbParagraphVO> queryPageList(@RequestBody ZtbParagraphVO query) {
        return ResultOne.ok(ztbParagraphService.queryPageList(query));
    }

    /**
     * 保存
     *
     * @param vo
     * @return
     */
    @ApiOperation(value = "标段表新增")
    @PutMapping(value = "/add")
    public Result<?> add(@Encrypt @RequestBody ZtbParagraph vo) {
        ztbParagraphService.save(vo);
        return Result.ok("添加成功！");
    }

    /**
     * 修改
     *
     * @param vo
     * @return
     */
    @ApiOperation(value = "标段表修改")
    @PostMapping(value = "/edit")
    public Result<?> edit(@Encrypt @RequestBody ZtbParagraph vo) {
        ztbParagraphService.updateById(vo);
        return Result.ok("编辑成功!");
    }

    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "标段表查询详情")
    @GetMapping("/get")
    public Result<ZtbParagraphVO> get(@RequestParam String id){
        return  Result.ok(ztbParagraphService.getById(id));
    }

    /**
     * 删除
     *
     * @param ids
     * @return
     */
    @ApiOperation(value = "删除")
    @PostMapping(value = "/delete")
    public Result<String> delete(@Encrypt @RequestBody Set<String> ids){
        ztbParagraphService.delete(ids);
        return Result.ok("删除成功!");
    }
    /**
     * 标段类型
     */
    @GetMapping("/getObjectType")
    public Result<?> getObjectType(){
        return  Result.ok(ztbParagraphService.getObjectType());
    }
    /**
     * 根据标段类型 查询标段信息
     */
    @PostMapping("/getZtbParagraphShow")
    public ResultOne<CimsProjectSectionInfoVO> getZtbParagraphShow(@RequestBody ZtbParagraphVO query) {
        return ResultOne.ok(ztbParagraphService.getZtbParagraphShow(query));
    }


}
